Skip to content

Conversation

@igamigo
Copy link
Collaborator

@igamigo igamigo commented Dec 28, 2025

This PR introduces 2 fixes:

  • (Closes debug assertions fail on integration tests #1402) When reconstructing the partial MMR, we were setting track_latest only based on whether there were client notes included in the block. This was not sufficient as track_latest is only meaningful if the leaf forms a single-leaf tree; in other situations the MMR code expects that the leaf will already be merged otherwise
  • Fixes the code that adjusts the authentication path for a smaller forest. The main thing there was that we were keeping "in-bounds" nodes (from the same subtree) that were still part of the largest forest's path, not the current smaller one. Also introduces some regression tests for this

It also adds a couple make commands to run tests with test-dev (introduced in #1400) to run tests with debug assertions

We should probably look into adding this to main as well

@igamigo igamigo force-pushed the igamigo-fix-debug-assertion branch from 76258ae to 95b7ab5 Compare December 29, 2025 00:18
@igamigo igamigo marked this pull request as ready for review December 29, 2025 00:19
@igamigo igamigo force-pushed the igamigo-fix-debug-assertion branch from 5e6cd95 to 329ea51 Compare December 29, 2025 02:28
@igamigo igamigo force-pushed the igamigo-fix-debug-assertion branch from 329ea51 to 077be9f Compare December 29, 2025 02:35
Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you! I left a couple of small comments inline - but other than that, this should be good to merge.

Comment on lines 109 to 111
let expected_depth = forest
.leaf_to_corresponding_tree(block_num.as_usize())
.expect("forest includes block number") as usize;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: technically what we get here is expected_path_len - expected depth would be expected_path_len + 1.

Also, I think the assert! on lines 104 - 107 is redundant with the expect() here. I think we can probably remove the assert!.

Comment on lines 116 to 126
for node in merkle_path.nodes().iter().take(expected_depth) {
let sibling = idx.sibling();
// NOTE: For a leaf that's in a smaller forest, all siblings within the tree depth should be
// in-bounds so this check and break are mostly redundant/should never be hit
// (iterating up to `expected_depth` handles it)
if sibling > rightmost_index {
break;
}
path_nodes.push((sibling, *node));
idx = idx.parent();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the comment says here, the sibling check is redundant. I'd probably just simplify this to be:

for node in merkle_path.nodes().iter().take(expected_depth) {
    path_nodes.push((idx.sibling(), *node));
    idx = idx.parent();
}

If we do want to be extra cautious, I'd convert the check into an assert!.

cargo nextest run --workspace $(EXCLUDE_WASM_PACKAGES) --exclude testing-remote-prover --release --test=integration --run-ignored ignored-only -- import_genesis_accounts_can_be_used_for_transactions

.PHONY: test-dev
test-dev: ## Run tests with debug assertions enabled via test-dev profile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should also change the CI job to try and catch if debug assertions fail

@mmagician mmagician merged commit a226748 into next Jan 12, 2026
28 checks passed
@mmagician mmagician deleted the igamigo-fix-debug-assertion branch January 12, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

debug assertions fail on integration tests

4 participants